<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 5/20/24
 * Time: 4:40 PM
 */

namespace App\Http\Resources;

use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class AdminResource extends JsonResource
{
    /**
     * 将资源转换成数组
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id'         => $this->id,
            'name'       => $this->name ?? '',
            'account'    => $this->account ?? '',
            'status'     => $this->status,
            'last_at'    => Carbon::parse($this->last_at)->toDateTimeString(),
            'last_ip'    => $this->last_ip,
            'created_at' => Carbon::parse($this->created_at)->toDateTimeString(),
            'updated_at' => Carbon::parse($this->updated_at)->toDateTimeString(),
        ];
    }
}
